package com.nuanshui.heatedloan.msgcenter.processor;

import java.util.HashMap;
import java.util.List;

import com.nuanshui.heatedloan.msgcenter.facade.smspush.SmsPushService;
import com.nuanshui.heatedloan.msgcenter.model.SmsMsg;
import com.nuanshui.heatedloan.msgcenter.model.SmsPushMsgBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.nuanshui.heatedloan.middleware.msgcenter.bean.MsgBody;

/**
 * 发送 短息具体处理类
 * @ClassName: SmsMsgProcessor
 * @author guohao
 * @date 2016年2月17日 上午11:02:21 
 *
 */
@Repository
public class SmsMsgProcessor implements MsgProcessor {
	
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private SmsPushService smsPushService;
	
	public void execute(MsgBody msgBody1) {

		SmsPushMsgBody msgBody=(SmsPushMsgBody)msgBody1;

		HashMap<String,Object> msgParams=msgBody.getParams();

		List<String> phones = msgBody.getPhones();
		for (String phone: phones) {
			SmsMsg msg=new SmsMsg();
			msg.setMobile(phone);
			msg.setTempCode(msgBody.getTemplateCode());
			msg.setParams(msgParams);
			msg.setSignName("秒借贷");
			if(msgBody.getBizType().equals(SmsMsg.TYPE_VERICODE.toString()))
			{
				msg.setBizType(SmsMsg.TYPE_VERICODE);
			}
			smsPushService.sendMsg(msg);
		}
	}
}
